﻿Module PluginSettingsHelper

    Friend Sub SavePluginSettings()

        'Plugin Einstellungen speichern
        For Each _plugin In GetPluginConnectorInstance.ClicknLoadPlugins

            If _plugin.HasSettings = True Then
                _plugin.SaveSettings()
            End If

        Next

        For Each _plugin In GetPluginConnectorInstance.CustomCommandPlugins

            If _plugin.HasSettings = True Then
                _plugin.SaveSettings()
            End If

        Next

    End Sub

    Friend Sub LoadPluginSettings()

        'Plugin Einstellungen laden - ClicknLoad
        For Each _plugin In GetPluginConnectorInstance.ClicknLoadPlugins

            If _plugin.HasSettings = True Then

                Dim _user_control As New UserControl

                _user_control = _plugin.GetSettingsTab

                _user_control.Dock = DockStyle.Fill

                frm_settings.TabControlMain_Settings.TabPages.Add(_plugin.GetName, _plugin.GetSettingsTabName)

                frm_settings.TabControlMain_Settings.TabPages(frm_settings.TabControlMain_Settings.TabCount - 1).Controls.Add(_user_control)
                frm_settings.TabControlMain_Settings.TabPages(frm_settings.TabControlMain_Settings.TabCount - 1).ImageIndex = 0

            End If

        Next

        For Each _plugin In GetPluginConnectorInstance.CustomCommandPlugins
            frm_settings.TabControlMain_Settings.TabPages.RemoveByKey(_plugin.GetName)
        Next

        'Plugin Einstellungen laden - Custom Command
        For Each _plugin In GetPluginConnectorInstance.CustomCommandPlugins

            If _plugin.HasSettings = True Then

                Dim _user_control As New UserControl

                _user_control = _plugin.GetSettingsTab

                _user_control.Dock = DockStyle.Fill

                frm_settings.TabControlMain_Settings.TabPages.Add(_plugin.GetName, _plugin.GetSettingsTabName)

                frm_settings.TabControlMain_Settings.TabPages(frm_settings.TabControlMain_Settings.TabCount - 1).Controls.Add(_user_control)
                frm_settings.TabControlMain_Settings.TabPages(frm_settings.TabControlMain_Settings.TabCount - 1).ImageIndex = 0

            End If

        Next

    End Sub

End Module